#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpatch/dpatch.make

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

build: build-stamp

build-stamp: patch
	dh_testdir
	$(MAKE)
	touch build-stamp

build-indep: build-indep-stamp

build-indep-stamp:
	python debian/dict-cdict.py \
	 | dictfmt -p --utf8 \
	           -u http://code.google.com/p/pkg-newedit/downloads/list \
		   -s cdict \
		   cdict
	dictzip cdict.dict
	touch build-indep-stamp
	
clean: clean1 unpatch
clean1:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp build-indep-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) clean
	rm -f cdict.dict cdict.dict.dz cdict.index
	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs

	# Add here commands to install the package into debian/cdict.
	$(MAKE) install DESTDIR=$(CURDIR)/debian/cdict

# Build architecture-independent files here.
binary-indep: build-indep
	dh_testdir
	dh_testroot
	dh_install
	dh_installchangelogs 
	dh_installdocs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_install
	dh_installchangelogs 
	dh_installdocs
	dh_installexamples
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

get-orig-source:
	cd ..; wget http://pkg-newedit.googlecode.com/files/cdict_0.1.orig.tar.gz

binary: binary-indep binary-arch
.PHONY: build clean clean1 binary-indep binary-arch binary install patch unpatch build-indep
